package com.clement.spring.study.reciever;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;

import javax.jms.*;

/**
 * Created by Clement on 2017/2/23.
 */
//@Component
public class JmsQueueSender {
    private JmsTemplate jmsTemplate;
    private Queue queue;

    @Autowired
    public void setConnectionFactory(ConnectionFactory connectionFactory) {
        this.jmsTemplate = new JmsTemplate(connectionFactory);
    }

    @Autowired
    public void setQueue(Queue queue) {
        this.queue = queue;
    }

    public void simpleSend() {
        this.jmsTemplate.send(this.queue, session -> session.createTextMessage("Hello World"));
    }
}
